﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using iTextSharp.text.pdf;
using PdfObjectInjection;

namespace PdfInjectExample
{
    class Program
    {
        private const string myLocation = @"..\..\ResultPdf\";
        private const string outputFileName = "result.pdf";
        private const string sourceLocation = @"..\..\GoodPdf\genapp.pdf";

        static void Main(string[] args)
        {
            if (!Directory.Exists(myLocation))
                Directory.CreateDirectory(myLocation);

            var employForm = new Forms.EmployementForm
                                 {
                                     FirstName = "Joe",
                                     MiddleName = "",
                                     LastName = "Somebody",
                                     AppAddress1 = "700 Penn Ave",
                                     AppAddress2 = "Not Where You Think it is, AK",
                                     EligibleInUS = "Yes", //this is case sensitive ... don't ask
                                     Permanent = "No"
                                 };
            
            var reader = new PdfReader(sourceLocation);
            var stream = new FileStream(myLocation + outputFileName, FileMode.Create);
            var stamp = new PdfStamper(reader, stream);

            var templateReader = new PdfReader(sourceLocation);
            var template = new FileStream(myLocation + "Template-" + outputFileName, FileMode.Create);
            var templateStamp = new PdfStamper(templateReader, template);

            PdfInject inject = new PdfInject(employForm, stamp.AcroFields);

            PdfTemplateInject templateInject = new PdfTemplateInject(employForm, templateStamp.AcroFields);

            stamp.Close();
            templateStamp.Close();
            
        }
    }
}
